Originally Posted by
MattieB
Ps: I know that I could rewrite my model to use Q_PROPERTIES, but I want it to be as framework independent as possible.
You don't need to use Qt properties in your model but it would be a good idea for the WorkflowQMLInterface class.
Something like this
class WorkflowQMLInterface
: public QObject{
Q_OBJECT
Q_PROPERTY(QStringList stepNames READ stepNames CONSTANT
) Q_PROPERTY(QString currentStep READ currentStep NOTIFY currentStepChanged
);
public:
QStringList stepNames
() const;
// return names of workflow steps
QString currentStep
() const;
// return name of current step, or change to int and use as index in stepNames
public slots:
void nextStep(); // advances the workflow, can also be a Q_INVOKABLE if you prefer
signals:
void currentStepChanged();
};
class WorkflowQMLInterface : public QObject
{
Q_OBJECT
Q_PROPERTY(QStringList stepNames READ stepNames CONSTANT)
Q_PROPERTY(QString currentStep READ currentStep NOTIFY currentStepChanged);
public:
QStringList stepNames() const; // return names of workflow steps
QString currentStep() const; // return name of current step, or change to int and use as index in stepNames
public slots:
void nextStep(); // advances the workflow, can also be a Q_INVOKABLE if you prefer
signals:
void currentStepChanged();
};
To copy to clipboard, switch view to plain text mode
In nextStep(), when you have change the current workflow has been changed by your model, emit currentStepChanged() so that the QML can react to that.
Cheers,
_
Bookmarks